package cn.nfwx.tv.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.greenrobot.eventbus.EventBus;

import cn.nfwx.tv.R;
import cn.nfwx.tv.base.BaseFragment;
import cn.nfwx.tv.events.ToLoginEvents;

/**
 * 空状态
 * Created by zb.liu on 2017/11/17.
 */
public class NullFragment extends BaseFragment implements View.OnClickListener {

    private TextView empty_login,empty_content,empty_text;
    private ImageView empty_image;
    private static String TYPE_KEY = "type_key";
    private int index;
    public static NullFragment newInstance(int index) {
        NullFragment fragment = new NullFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(TYPE_KEY, index);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public View initView() {
        View view=View.inflate(mContext, R.layout.fragment_null,null);
        empty_login=findView(view,R.id.empty_login);
        empty_content=findView(view,R.id.empty_content);
        empty_text=findView(view,R.id.empty_text);
        empty_image=findView(view,R.id.empty_image);
        empty_login.setOnClickListener(this);
        return view;
    }

    @Override
    public void initData() {
        super.initData();
        index = getArguments().getInt(TYPE_KEY);
        if(index==2){
            empty_text.setText("暂无订阅");
            empty_content.setText("可订阅精彩节目");
            empty_image.setImageResource(R.mipmap.empty_subscribe);
        }else if(index==3){
            empty_text.setText("暂无预约");
            empty_content.setText("可预约精彩节目");
            empty_image.setImageResource(R.mipmap.empty_order);
        }else if(index==4){
            empty_text.setText("暂无观看记录");
            empty_content.setText("可去观看精彩节目");
            empty_image.setImageResource(R.mipmap.empty_record);

        }else if(index==5){
            empty_text.setText("暂无下载");
            empty_content.setText("可下载精彩节目");
            empty_image.setImageResource(R.mipmap.empty_download);
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.empty_login:
                EventBus.getDefault().post(new ToLoginEvents(0));
                break;

        }
    }
}
